#include "Nano100Series.h"
#include "SysTick.h"
#include "Common.h"

static uint32_t timer0_counter = 0;

void TMR0_IRQHandler(void)
{
    timer0_counter += 1;
    //LogDebug("%d sec\n", timer0_counter);
    TIMER_ClearIntFlag(TIMER0);
}

void SysTickInit(void)
{
    TIMER_Open(TIMER0, TIMER_PERIODIC_MODE, 1);
    TIMER_EnableInt(TIMER0);
    NVIC_EnableIRQ(TMR0_IRQn);
    TIMER_Start(TIMER0);
}

uint32_t SysTickGet(void)
{
	return timer0_counter;
}
